package org.jgs1904.multithreading_001;

import java.util.concurrent.*;

/**
 * @author: 默苍璃
 * @date: 2024-11-05 15:35
 */
public class Test01 {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        Thread thread1 = new Thread() {
            @Override
            public void run() {
                System.out.println("hello");
            }

        };

        thread1.start();


        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("thread2");
            }
        });

        thread2.start();


        ExecutorService executor = Executors.newSingleThreadExecutor();

        executor.execute(new Runnable() {
            @Override
            public void run() {
                System.out.println("execute");
            }
        });

        Future<String> submit = executor.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                //System.out.println("call");
                return "call";
            }
        });
        String future = submit.get();
        System.out.println(future);

    }

}
